<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>专业数据处理平台</title>
    <meta name="description" content="这是一个 queueRegister 页面">
    <meta name="keywords" content="queueRegister">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="${ctx}/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="${ctx}/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="${ctx}/assets/css/bootstrap.css">
    <link rel="stylesheet" href="${ctx}/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="${ctx}/assets/css/admin.css">
    <link rel="stylesheet" href="${ctx}/assets/css/app.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/xcConfirm.css"/>
</head>

<body data-type="chart">
        <!--标题-->
        <div class="tpl-content-page-title">
            工作流系统--队列
        </div>
        <!--面包屑-->
        <ol class="am-breadcrumb">
            <li><a href="#" class="am-icon-home">首页</a></li>
            <li><a href="#">调度</a></li>
            <li class="am-active">作业队列提交</li>
        </ol>
		  <form id='addQueue' action="${ctx}/conf/queues.action" method='post' class="am-form am-form-horizontal" >
        <div class="tpl-portlet-components">

            <div class="tpl-portlet-components">

                <div class="portlet-title">
                    <div class="caption font-green bold">
                        作业队列提交
                    </div>
                </div>

                <div class="am-tabs tpl-index-tabs" data-am-tabs="{noSwipe: 1}">
						
                    <ul class="am-tabs-nav am-nav am-nav-tabs">
                        <li class="am-active"><a href="#tab1">基本信息</a></li>
                        <li><a href="#tab2">高级配置</a></li>
                        <li><a href="#tab3" onclick="checkInfo()">详情预览</a></li>
                    </ul>
							
                    <div class="am-tabs-bd">
                        <div class="am-tab-panel am-fade am-in am-active" id="tab1">
                            <div class="tpl-portlet-components">
                                <div class="portlet-title">
                                    <div class="caption font-green">
                                        作业基本信息
                                    </div>
                                </div>
                                <div class="am-g tpl-amazeui-form">
                                    <div class="am-u-sm-12">
<!--                                         <form class="am-form am-form-horizontal"> -->
                                            <div class="am-form-group">
                                                <label for="QUEUE_NAME" class="am-u-sm-3 am-form-label">队列名称</label>
                                                <div class="am-u-sm-6">
                                                    <input type="text" id="QUEUE_NAME" name="QUEUE_NAME" placeholder="队列名称"/>
                                                </div>
                                                <p id="check_name_div" class="am-u-sm-3" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group">
                                                <label for="PRIORITY" class="am-u-sm-3 am-form-label">队列优先级</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="1" max="100" id="PRIORITY" name="PRIORITY" value='1' placeholder="作业优先级 1-100(100最高)"/>
                                                </div>
                                                <p id="check_priority_div" class="am-u-sm-3" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group">
                                                <label for="QJOB_LIMIT" class="am-u-sm-3 am-form-label">队列作业槽个数</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0" id="QJOB_LIMIT" name="QJOB_LIMIT" placeholder="队列作业槽个数"/>
                                                </div>
                                                <p id="check_job_slot_div" class="am-u-sm-3" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group">
                                                <label for="PREEMPTION"
                                                       class="am-u-sm-3 am-form-label">队列抢占</label>
                                                <div class="am-u-sm-6 am-form">
                                                    <select id="PREEMPTION" name="PREEMPTION">
                                                        <option value=" " disabled="disabled" selected="selected">
                                                            -请选择队列类型
                                                        </option>
                                                        <option value="PREEMPTIVE">抢占队列</option>
                                                        <option value="PREEMPTABLE">可抢占队列</option>
                                                        <option value="PREEMPTIVEPREEMPTABLE">抢占队列和可抢占队列</option>
                                                    </select>
                                                </div>
                                                <p id="check_queue_type_div" class="am-u-sm-3" style="margin-top: 5px;"></p>
                                                <span class="am-form-caret"></span>
                                            </div>

<!--                                         </form> -->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-tab-panel am-fade" id="tab2">
                            <div class="tpl-portlet-components">
                                <div class="portlet-title">
                                    <div class="caption font-green">
                                        处理命令
                                    </div>
                                </div>
                                <div class="am-g tpl-amazeui-form">
                                    <div class="am-u-sm-12">
<!--                                         <form class="am-form am-form-horizontal"> -->
                                            <div class="am-form-group" id="pre_command_div">
                                                <label for="PRE_EXEC" class="am-u-sm-3 am-form-label">预处理命令</label>
                                                <div class="am-u-sm-6">
                                                    <input type="text" id="PRE_EXEC" name="PRE_EXEC" value=' ' placeholder="预处理命令"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_pre_command_div" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group" id="post_command_div">
                                                <label for="post_command" class="am-u-sm-3 am-form-label">后处理命令</label>
                                                <div class="am-u-sm-6">
                                                    <input type="text" id="post_command"  value='0' placeholder="后处理命令"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_post_command_div" style="margin-top: 5px;"></p>
                                            </div>
<!--                                         </form> -->
                                    </div>
                                </div>
                                <div class="portlet-title">
                                    <div class="caption font-green">
                                        队列资源预留
                                    </div>
                                </div>
                                <div class="am-g tpl-amazeui-form">
                                    <div class="am-u-sm-12">
<!--                                         <form class="am-form am-form-horizontal"> -->
                                            <div class="am-form-group" id="memorynum_div">
                                                <label for="memorynum" class="am-u-sm-3 am-form-label">内存使用量</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0"  id="memorynum"  value='0' name='RES_REQ_MEM'placeholder="内存使用量"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_memorynum_div" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group" id="exchange_area_div">
                                                <label for="exchange_area" class="am-u-sm-3 am-form-label">交换区使用量</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0"  id="exchange_area"  value='0' name='RES_REQ_SWAP' placeholder="交换区使用量"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_exchange_area_div" style="margin-top: 5px;"></p>
                                            </div>
<!--                                             <input type="hidden" id="job-starter"  value='c:/unischeduler/bin/jobstart/jhexec_cmd.bat'  placeholder="交换区使用量"/> -->
<!-- <!--                                         </form> --> 
                                    </div>
                                </div>
                                <div class="portlet-title">
                                    <div class="caption font-green">
                                        资源限制
                                    </div>
                                </div>
                                <div class="am-g tpl-amazeui-form">
                                    <div class="am-u-sm-12">
<!--                                         <form class="am-form am-form-horizontal"> -->
                                            <div class="am-form-group" id="max_time_div">
                                                <label for="RUNLIMIT" class="am-u-sm-3 am-form-label">最大运行时间</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0"  id="RUNLIMIT" name='RUNLIMIT' value="0" placeholder="最大运行时间"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_max_time_div" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group" id="limit_memorynum_div">
                                                <label for="MEMLIMIT" class="am-u-sm-3 am-form-label">内存使用量</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0"  id="MEMLIMIT" name='MEMLIMIT' value='0' placeholder="内存使用量"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_limit_memorynum_div" style="margin-top: 5px;"></p>
                                            </div>
<!--                                         </form> -->
                                    </div>
                                </div>
                                <div class="portlet-title">
                                    <div class="caption font-green">
                                        队列负载阈值
                                    </div>
                                </div>
                                <div class="am-g tpl-amazeui-form">
                                    <div class="am-u-sm-12">
<!--                                         <form class="am-form am-form-horizontal"> -->
                                            <div class="am-form-group" id="memory_div">
                                                <label for="memory" class="am-u-sm-3 am-form-label">内存</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0"  id="memory" value='0' placeholder="内存"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_memory_div" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group" id="exchange_div">
                                                <label for="exchange" class="am-u-sm-3 am-form-label">交换区</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number" min="0"  id="exchange"  value='0'placeholder="交换区"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_exchange_div" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group" id="scheduling_threshold_div">
                                                <label for="scheduling_threshold" class="am-u-sm-3 am-form-label">限制进程调度阈值</label>
                                                <div class="am-u-sm-6">
                                                    <input type="number"  min="0" id="scheduling_threshold" value='0' placeholder="限制进程调度阈值"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_scheduling_threshold_div" style="margin-top: 5px;"></p>
                                            </div>

                                            <div class="am-form-group" id="suspend_threshold_div">
                                                <label for="exchange" class="am-u-sm-3 am-form-label">限制进程挂起阈值</label>
                                                <div class="am-u-sm-6">
                                                    <input type="text"   id="LIMITED_PROCESS" name='LIMITED_PROCESS' value='0' placeholder="限制进程挂起阈值"/>
                                                </div>
                                                <p  class="am-u-sm-3" id="check_suspend_threshold_div" style="margin-top: 5px;"></p>
                                            </div>
<!--                                         </form> -->
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="am-tab-panel am-fade" id="tab3">
                            <div class="tpl-portlet-components">
                                <div class="portlet-title">
                                    <div class="caption font-green">
                                        详情预览
                                    </div>
                                    <div class="action" style="float: right;">
                                        <ul class="actions-btn">
                                            <li class="blue" onclick="sub()">注册</li>
                                        </ul>
                                    </div>
                                </div>
                                <div class="am-g tpl-amazeui-form">
                                    <div class="am-u-sm-12 am-u-md-12" id="deleteLable">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
						
                </div>

            </div>


        </div>
      </form>

<script src="${ctx}/assets/js/jQuery/jquery.min.js"></script>
<script src="${ctx}/assets/js/jQuery/jquery-1.9.1.js"></script>
<script src="${ctx}/assets/js/jQuery/jquery-form.js"></script>
<script src="${ctx}/assets/js/common/xcConfirm.js"></script>
<%-- <script src="${ctx}/assets/js/utils.js"></script> --%>
<script src="${ctx}/assets/js/common/config.js"></script>
<script src="${ctx}/assets/js/common/amazeui.min.js"></script>
<script src="${ctx}/assets/js/common/app.js"></script>
<script src="${ctx}/assets/js/layer/layer.js"></script>
<script>
function sub() {		
	console.info($('#addQueue').serialize());
   console.info($('#addQueue').serializeArray());
	 $.ajax({
         method : 'post',
         url : constUrl+'conf/queues.action',
         dateType:'json',
         data : $('#addQueue').serializeArray(),
         success : function(data) {
        	 	if(data.resultCode=='000000'){
        	 		alert("创建成功")
        	 	}else
        	 		alert(data.desc)
            //alert(data);
         }
     });
	return false;
}
function checkInfo(){
	var QUEUE_NAME = $("#QUEUE_NAME").val();
    var QJOB_LIMIT = $("#QJOB_LIMIT").val();
    var PRIORITY=$("#PRIORITY").val();
    var PREEMPTION = $("#PREEMPTION").val();
    var MEMLIMIT = $("#MEMLIMIT").val();
    var RUNLIMIT = $("#RUNLIMIT").val();
    var PRE_EXEC = $("#PRE_EXEC").val();
    if(PREEMPTION=="PREEMPTIVE")PREEMPTION="抢占队列";
    if(PREEMPTION=="PREEMPTABLE")PREEMPTION="可抢占队列";
    if(PREEMPTION=="PREEMPTIVEPREEMPTABLE")PREEMPTION="抢占队列和可抢占队列";
	//alert(PRIORITY);
	//alert($("#PRIORITY").val())
    var tableHtml = '<div class="am-u-sm-12 am-u-md-12" id="infoTable"><table class="am-table am-table-bordered am-table-radius am-table-striped">' +
        '<tr><td style="width: 150px">队列名称</td><td  style="width: 295px">'+QUEUE_NAME+'</td><td style="width: 150px">优先级</td><td style="width: 295px">'+PRIORITY+'</td></tr>' +
        '<tr><td>作业槽数</td><td>'+QJOB_LIMIT+'</td><td>抢占策略</td><td>'+PREEMPTION+'</td></tr>' +
        '<tr><td>最大运行时间</td><td>'+RUNLIMIT+'</td><td>内存限制</td><td>'+MEMLIMIT+'</td></tr>';
//     if (work_style=="definiteTime"){
//         tableHtml += '<tr><td>开始时间</td><td>'+sTime+'</td><td>结束时间</td><td>'+eTime+'</td></tr>';
//     }
//     tableHtml += '<tr><td>内存使用量</td><td>'+memorynum+'</td><td>所需CPU核数</td><td>'+cpunum+'</td></tr>';
//     if (MPI=="true"){
//         tableHtml += '<tr><td>是否使用GPU</td><td>'+GPU_string+'</td><td></td><td></td></tr>' +
//             '<tr><td>是否为MPI</td><td>'+MPI_string+'</td><td>MPI进程数</td><td>'+mpinum+'</td></tr>';
//     } else {
//         tableHtml += '<tr><td>是否使用GPU</td><td>'+GPU_string+'</td><td>是否使用GPU</td><td>'+MPI_string+'</td></tr>';
//     }

    tableHtml += '</table>' +
        '<table class="am-table am-table-bordered am-table-radius am-table-striped">' +
        '<tr><td style="width: 150px">预处理命令</td><td>'+PRE_EXEC+'</td></tr>' +
        '</table></div>';
	$("#deleteLable").html(tableHtml);
}
</script>
</body>

</html>